{namespace partychapp.templates}

/**
 * Build score table.
 * @param channelName
 * @param targets
 */
{template .scoreTable}
  <table class="channel-table">
    <tr>
      <th class="target-cell" id="target-name-header" style="cursor: pointer; cursor: hand">Target</th>
      <th class="score-cell" id="target-score-header" style="cursor: pointer; cursor: hand">Score</th>
    </tr>
    {if length($targets) == 0}
      <tr>
        <td>No scores yet! Start ++'ing and --'ing stuff!</td>
      </tr>
    {else}
      {foreach $target in $targets}
        {call .singleTarget}
          {param channelName: $channelName /}
          {param target: $target /}
        {/call}
      {/foreach}
    {/if}
  </table>
{/template}

/**
 * One row for one target.
 * @param channelName
 * @param target
 */
{template .singleTarget}
  <tr>
    <td class="target-cell">
      <div class="target-name" onclick="toggleTargetDetails(this, '{$channelName}', '{$target['name']}')">
        {$target['name']}
      </div>
    </td>
    <td class="score-cell">{$target['score']}</td>
  </tr>
{/template}
 